<?php
$this->headTitle($this->translator('enterprise_request_partner'));
?>

<?php
    $enterprise = $this->enterprise;

    $arrRoute = array(
        'enterprise_id' => $enterprise->id,
        'enterprise_name' => Tomato_Utility_String::removeSign($enterprise->company_name_en, '-', true)
    );
?>
<div class="subcolumns tabs pb10">
    <ul class="tabNavigation">
        <li><a href="<?php echo $this->url($arrRoute, 'bizprofile_partner_list');?>"><?php echo $this->translator('enterprise_is_partner')?></a></li>
		<?php if($this->isLogin && $this->isUserOfEnt):?>
        <li><a class="selected" href="#"><?php echo $this->translator('enterprise_request_partner')?></a></li>
        <li><a href="<?php echo $this->url($arrRoute, 'bizprofile_partner_pending');?>"><?php echo $this->translator('enterprise_pending_partner')?></a></li>
		<?php endif;?>
    </ul>
</div>
<?php if(count($this->partners) > 0) : ?>
<div class="t_news_tag notify" id="tab1">
    <?php foreach ($this->partners as $row) : ?>
    <div class="notify-item ">
        <div class="item">
            <h3>
            <?php
                $arrParamEnterprise = array(
                    'enterprise_id' => $row->enterprise_id,
                    'enterprise_name' => Tomato_Utility_String::removeSign($row->company_name_en, '-', true)
                );
            ?>
            <a href="<?php echo $this->url($arrParamEnterprise, 'bizprofile_enterprise_index'); ?>">
                <?php echo $this->lang == "en" ? $row->company_name_en : $row->company_name_vn; ?>
            </a>
            </h3>
            <div>
                <div>
                    <span style="float:left;width: 400px"><b>email</b> : <?php echo $row->contact_email ?> &nbsp; <b>tel</b> : <?php echo $row->contact_tel ?></span>
                    <span style="float:left;width: 180px;text-align:right; padding-right: 5px;">
                        <?php if($row->partner_status == 'no'): ?>
                            <?php echo $this->translator('partner_waiting_response');?>
                        <?php elseif($row->partner_status == 'pending'): ?>
                            <?php echo $this->translator('partner_pending');?>
                        <?php else: ?>
                            <?php echo $this->translator('partner_in_relationship');?>
                        <?php endif; ?>
					</span>					
					<?php if($this->isLogin && $this->isUserOfEnt && $this->allow('remove-partner') ): ?>
					<span style="float:left;width: 25px;text-align:right;">
						<!--remove partner waiting-->	
						<form id="removePartner_<?php echo $row->enterprise_id; ?>" method="post" action="<?php echo $this->url(array(), 'bizprofile_partner_remove_partner'); ?>" >
							<input type="hidden" name="enterprise_id" value="<?php echo $enterprise->id ?>" />
							<input type="hidden" name="relation_id" value="<?php echo $row->enterprise_id; ?>" />
							<input type="hidden" name="partnerAction" value="waiting"/>
							<a  class="waitingRemove" rel="<?php echo $row->enterprise_id;?>" href="javascript:void(0)"><?php echo $this->translator('enterprise_delete_partner');?></a>	
						</form>
						<!--end remove partner waiting-->		
                    </span>
					<?php endif;?>
					
                </div>
                <div style="clear:both;"></div>
            </div>
        </div>
    </div>
    <?php endforeach; ?>

    <div class="paginator">
        <?php echo $this->paginator()->slide($this->paginator, $this->paginatorOptions); ?>
    </div>
</div>
<?php endif; ?>
<script type="text/javascript" charset="utf-8">
	$(".waitingRemove").click(function(){
		if (confirm("<?php echo $this->translator('partner_remove_partner'); ?>"))
		{
			var rel = $(this).attr('rel');
			$("#removePartner_"+rel).submit();
		}
	});       
</script>